<template>
  <el-select-v2
    filterable
    clearable
    placeholder="请选择"
    v-bind="$attrs"
    :options="list"
  >
  </el-select-v2>
</template>

<script lang="ts" setup name="supplierSelect">
import { readAllSupplier } from '/@/api/supplier';
import { ref, onMounted } from 'vue';
import { padStart } from 'lodash';

const list = ref([]);

const fetchData = async () => {
  const { data } = await readAllSupplier();
  list.value = data.list.map((item: any) => {
    return {
      value: item.id,
      label: `(${padStart(item.code, 4, '0')})${item.name}`
    };
  });
};

onMounted(() => {
  fetchData();
});
</script>
